package com.bawei.bydayzg_two.adapter

import android.graphics.Color
import android.widget.LinearLayout
import com.bawei.base.bean.CartGoreyResultItem
import com.bawei.bydayzg_two.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class ONeAdapter:BaseQuickAdapter<CartGoreyResultItem,BaseViewHolder>(R.layout.item_one) {
    var index = 515
    //
    override fun convert(holder: BaseViewHolder, item: CartGoreyResultItem) {
        holder.setText(R.id.one_tv,item.name)
        //
        if (index == item.id){
            holder.setTextColor(R.id.one_tv,Color.RED)
            holder.getView<LinearLayout>(R.id.one_ll).setBackgroundResource(R.drawable.bg_one)
        } else {
            holder.setTextColor(R.id.one_tv,Color.BLACK)
            holder.getView<LinearLayout>(R.id.one_ll).background = null
        }
    }
    //
    fun getIndex(position:Int){
        index = position
        //
        notifyDataSetChanged()
    }
}